/*!
 * \file frct_hash_init.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frlog.h"
#include "frmem.h"
#include "frlist.h"
#include "frsutl.h"
#include "frhash2.h"
#include "conntrack.h"
#include "frct_comm.h"
#include "frct_hash.h"
#include "frct_mng.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

extern Frhash_header        *g_p_st_hash_ct;

void __hash_node_free(Frlist_node *p_st_node);
static void __case1(void)
{
    int i_ret = 0;
    unsigned int ui_table_size = 65535;

    g_p_st_hash_ct=NULL;
    i_ret = frct_hash_init(ui_table_size);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);
    CU_ASSERT_EQUAL(g_p_st_hash_ct->ul_hash_size,65535);

    frhash2_free2(g_p_st_hash_ct,__hash_node_free);
    return;
}

static void __case2(void)
{
    int i_ret = 0;
    unsigned int ui_table_size = 65534;

    g_p_st_hash_ct=NULL;
    i_ret = frct_hash_init(ui_table_size);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);
    CU_ASSERT_EQUAL(g_p_st_hash_ct->ul_hash_size,65536);

    frhash2_free2(g_p_st_hash_ct,__hash_node_free);
    return;
}

static void __case3(void)
{
    int i_ret = 0;
    unsigned int ui_table_size = 65536;

    g_p_st_hash_ct=NULL;
    i_ret = frct_hash_init(ui_table_size);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);
    CU_ASSERT_EQUAL(g_p_st_hash_ct->ul_hash_size,65536);

    frhash2_free2(g_p_st_hash_ct,__hash_node_free);
    return;
}

static void __case4(void)
{
    int i_ret = 0;
    unsigned int ui_table_size = 0;

    g_p_st_hash_ct=NULL;
    i_ret = frct_hash_init(ui_table_size);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);
    CU_ASSERT_EQUAL(g_p_st_hash_ct->ul_hash_size,65536);

    frhash2_free2(g_p_st_hash_ct,__hash_node_free);
    return;
}

int add_suite_frct_hash_init(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frct_hash frct_hash_init()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);
    CU_add_test(pSuite, "case4", __case4);

    return FR_SUCC;
}
